<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>${menuDetail.name}</title>
<#include "/admin/main/include/link_head.ftl"/>
</head>

<body class="jr-body">
<div class="jr-main-content">
<@tags.editBtns btns="close" />
    <div style="margin-top: 70px;"></div>
    <div class="wrapper">
        <div class="row">
            <div class="col-md-5">
            <@tags.table id="easyui-datagrid-left" options="bodyCls:'jr-easyui-body jr-no-pagination-info',
            url:'menuPage?gid=${gid}',
            singleSelect:true,
            onSelect:'onLeftSelect'">
                <@tags.th options="field:'ck',checkbox:true"></@tags.th>
                <@tags.th options="field:'name',width:150,sortable:false,formatter:'uiLink'"><@spring.message '菜单名称' /></@tags.th>
            </@tags.table>
            <@tags.gridBtns id="tbMain" btns="search,add,remove,sort" urls="add:'menuEdit.do?gid=${gid}'" />
            <@tags.gridCons gridId="easyui-datagrid-left" forms="[
                        {
                            type:'text',
                            field:'name',
                            op:'like',
                            text:'姓名'
                        },
                        {
                            type:'select',
                            field:'typeId',
                            op:'like',
                            text:'类型'
                        },
                        {
                            type:'date',
                            field:'addDate',
                            op:'between',
                            text:'添加时间'
                        },
                        {
                            type:'date',
                            field:'updateDate',
                            op:'eq',
                            text:'修改时间'
                        },
                        {
                            type:'tree',
                            field:'typeId',
                            op:'eq',
                            text:'区域'
                        }
                    ]" />
            </div>
            <div class="col-md-7">
            <@tags.treetable id="easyui-datagrid-right" options="toolbar:'#tbSlave',
            url:'../common-menu/rightPage',
            pagination:false,
            idField:'id',
            singleSelect:true,
            onContextMenu:'onRightContextMenu',
            treeField: 'name'">
                <@tags.th options="field:'ck',checkbox:true,sortable:false"></@tags.th>
                <@tags.th options="field:'name',width:200,formatter:'uiLink',sortable:false"><@spring.message '菜单名称' /></@tags.th>
                <@tags.th options="field:'linkOther',width:270,sortable:false,formatter:'uiMenuLink'"><@spring.message '菜单链接' /></@tags.th>
            </@tags.treetable>
            <@tags.gridBtns id="tbSlave" btns="search,add,remove,sort" urls="add:'menuEdit?gid=${gid}'" />
            <@tags.gridCons gridId="easyui-datagrid-right" forms="[
                        {
                            type:'text',
                            field:'name',
                            op:'like',
                            text:'姓名'
                        }
                    ]" />
                <div id="mm" class="easyui-menu" style="width:120px;">
                    <div data-options="iconCls:'icon-add'"><@spring.message '增加子菜单' /></div>
                </div>
            </div>
        </div>

    </div>
</div>
</body>
</html>
<#include "/admin/main/include/link_foot.ftl"/>
<script type="text/javascript">
    function uiMenuLink(value, row, index) {
        var htm = "<@spring.url '/admin/plugin/' />";
        htm += row.pluginId + "/" + row.linkOther;
        return htm;
    }
    function onLeftSelect(rowIndex, rowData) {
        $("#easyui-datagrid-right").treegrid("load", {
            'search.eq.pid': rowData.id
        });
    }
    $(function () {
        $("#tbSlave .jr-add").unbind("click");
        $("#tbSlave .jr-add").click(function () {
            var selected = $("#easyui-datagrid-left").datagrid("getSelected");
            if (null == selected) {
                alert("请先选择左侧主菜单。");
                return false;
            }
            var id = selected.id;
            win("menuEdit?gid=${gid}&pid=" + id + "&mid=${menuDetail.id}");
        });
    })
    function onRightContextMenu(e, row) {
        if (row) {
            e.preventDefault();
            $(this).treegrid('select', row.id);
            $('#mm').menu('show', {
                left: e.pageX,
                top: e.pageY,
                onClick: addRightMenu
            });
        }
    }
    function addRightMenu(item) {
        var selected = $("#easyui-datagrid-right").datagrid("getSelected");
        if (null != selected) {
            win("menuEdit.do?gid=${gid}&pid=" + selected.id + "&mid=${menuDetail.id}");
        }
    }
</script>